

Imports System
Imports System.Collections.Generic
' para leer archivos de configuracion en xml
Imports Nini.Config


' ----------------------------------------------------------------------------
' en esta clase ponemos todos los datos de configuracion
' utilizo el modelo singleton para que solo haya una implementacion
' propiedades:

' ----------------------------------------------------------------------------
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Public Class paquete
    Public Shared s As paquete
    Public Shared flag As Boolean

    ' propiedades a tocar


#Region "Propiedades"


    Private _DirectoriosACopiar As String()
    Public Property DirectoriosACopiar() As String()
        Get
            Return _DirectoriosACopiar
        End Get
        Set(ByVal Value As String())
            _DirectoriosACopiar = Value
        End Set
    End Property


    Private _Descripcion As String()
    Public Property Descripcion() As String()
        Get
            Return _Descripcion
        End Get
        Set(ByVal Value As String())
            _Descripcion = Value
        End Set
    End Property



    Private _Plantillas As String()
    Public Property Plantillas() As String()
        Get
            Return _Plantillas
        End Get
        Set(ByVal Value As String())
            _Plantillas = Value
        End Set
    End Property



    Private _PlantillasEstaticas As String()
    Public Property PlantillasEstaticas() As String()
        Get
            Return _PlantillasEstaticas
        End Get
        Set(ByVal Value As String())
            _PlantillasEstaticas = Value
        End Set
    End Property


#End Region

    Private source As XmlConfigSource

    Private Sub New(ByVal paquete As String)

        source = New XmlConfigSource(IO.Path.Combine(util.ubicacionPaquetes, paquete))

    End Sub

    Friend Shared Function getConfig(ByVal paquete As String) As paquete
        If flag = False Then
            'First instance
            'return a new object
            s = New paquete(paquete)
            flag = True
            Return s
        Else
            'future object request
            'return an already created object
            Return s
        End If
    End Function

     

    ' carga valores del registro
    Public Sub CargarDatosRegistro()

        Try

            Me.DirectoriosACopiar = source.Configs("pack").Get("DirectoriosACopiar").Split("|")
            Me.Plantillas = source.Configs("pack").Get("Plantillas").Split("|")
            Me.PlantillasEstaticas = source.Configs("pack").Get("PlantillasEstaticas").Split("|")

            Me.descripcion = source.Configs("pack").Get("Descripcion").Split("|")


        Catch ex As Exception
        Finally


        End Try

    End Sub

    Public Sub GuardarDatosRegistro()
        Try


            Dim configSettings As IConfig = source.Configs("log")

            ' configSettings.Set("NombreUsuario", Me.NombreUsuario)

            source.Save()


        Catch ex As Exception
        Finally
            ' key = Nothing
        End Try

    End Sub


End Class
